package jdbc;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Statement;

public class Demo9 {
    public static void main(String[] args) {
        try (Connection con=DBUtil.getConnection();){
            String sql= "UPDATE user "+
                        "SET username=?,nickname=?,age=?  "+
                        " WHERE username=?";
            PreparedStatement pre=con.prepareStatement(sql);
            pre.setString(1,"皮皮");
            pre.setString(2,"落魄山");
            pre.setInt(3,19);
            pre.setString(4,"陈平安");
            int num=pre.executeUpdate();
            System.out.println(num>0?"更新成功":"更新失败");
        } catch (SQLException e) {
            e.printStackTrace();
        }


    }
}
